//package com.navinfo.platform.producer;
//
//
//
//import org.apache.kafka.clients.producer.KafkaProducer;
//import org.apache.kafka.clients.producer.ProducerConfig;
//import org.apache.kafka.clients.producer.ProducerRecord;
//import org.apache.kafka.common.serialization.ByteArraySerializer;
//import org.apache.kafka.common.serialization.StringSerializer;
//
//import java.util.Properties;
//
///**
// * Created by chen on 2019/7/23.
// */
//public class Producer_d002 {
//    public static String topic = "d002PB";
//
//    public static void main(String[] args) throws InterruptedException {
//        Properties p = new Properties();
//        p.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "platform-010-030-050-177:9092");
//        p.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
//        p.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class);
//        KafkaProducer<String, byte[]> kafkaProducer = new KafkaProducer(p);
//
//        try {
//            long time = 1563933891L;
//            LCTireTemperatureDFAddition.TireTemperatureDFAddition.Builder builder = LCTireTemperatureDFAddition.TireTemperatureDFAddition.newBuilder();
//            builder.setAlarmSign(1);
//            builder.setDirection(2);
//            builder.setGpsSpeed(3);
//            builder.setGpsTime(time);
//            builder.setHeight(4);
//            builder.setLatitude(5);
//            builder.setLongitude(6);
//            builder.setSerialNumber(0);
//            builder.setStatus(7);
//            builder.setTerminalId(64896411994l);
//            builder.setTyreCount(8);
//            builder.setVehType(9);
//            LCTireTemperatureDFAddition.TireConditionItem.Builder builder1 = LCTireTemperatureDFAddition.TireConditionItem.newBuilder();
//            builder1.setAirLeakage(0);
//            builder1.setBatteryStatus(1);
//            builder1.setHighTemperature(2);
//            builder1.setNoMatch(3);
//            builder1.setNoRFSignal(4);
//            builder1.setPlaceholder1(5);
//            builder1.setPlaceholder2(6);
//            builder1.setTemAlarmThreshold(7);
//            builder1.setTfaStatus(8);
//            builder1.setTireLocation(9);
//            builder1.setTirePressureAlarm(10);
//            builder1.setTyreBurstStatus(11);
//            builder.addTireConditionItem(builder1);
//            LCTireTemperatureDFAddition.TireConditionItem.Builder builder2 = LCTireTemperatureDFAddition.TireConditionItem.newBuilder();
//            builder2.setAirLeakage(110);
//            builder2.setBatteryStatus(111);
//            builder2.setHighTemperature(112);
//            builder2.setNoMatch(113);
//            builder2.setNoRFSignal(114);
//            builder2.setPlaceholder1(115);
//            builder2.setPlaceholder2(116);
//            builder2.setTemAlarmThreshold(117);
//            builder2.setTfaStatus(118);
//            builder2.setTireLocation(119);
//            builder2.setTirePressureAlarm(1110);
//            builder2.setTyreBurstStatus(1111);
//            builder.addTireConditionItem(builder2);
//
//            for(int i=0;i<10000;i++) {
//                builder.setSerialNumber(i);
//                builder.setGpsTime(time+i);
//
//                ProducerRecord<String, byte[]> record = new ProducerRecord<String, byte[]>(topic, builder.build().toByteArray());
//                kafkaProducer.send(record);
//                System.out.println("消息发送成功:" + i);
//                Thread.sleep(5);
//            }
//        }
//        catch (Exception e){
//            e.printStackTrace();
//        }
//        finally {
//            kafkaProducer.close();
//        }
//
//    }
//}
